package com.aaa.marketresearch.webclient.gwt.domain;

import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Nail
 */

public class Bill {

    private Integer id;

    private String familyMemberName;

    private String created;

    private List<BillContent> content;

    public Integer getId() {
        return id;
    }

    public String getFamilyMemberName() {
        return familyMemberName;
    }

    public String getCreated() {
        return created;
    }

    public List<BillContent> getContent() {
        return content;
    }

    public Bill(JSONObject jObj) {
        this.id = (int)jObj.get("id").isNumber().doubleValue();
        this.created = jObj.get("created").isString().stringValue();

        JSONArray data = jObj.get("content").isArray();
        int n = data.size();
        this.content = new ArrayList<BillContent>();

        for (int i = 0; i < n; i++) {
            BillContent billContent = new BillContent(data.get(i).isObject());
            this.content.add(billContent);
        }
    }
}
